package com.zxx.pattern.compositePattern.composite3;

/**
 * @author zxx on 2021/5/21
 */
public class TestClient {
    public static void main(String[] args) {
        //文件系统
        //总文件
        //--a.txt, b.jpg, c文件夹
        //------------------c_1.text  c_1.rmvb    c_1.jpg
        Folder folder = new Folder("总文件夹");
        TextFile textFile1 = new TextFile("a.txt");
        ImagerFile imagerFile1 = new ImagerFile("b.jpg");
        Folder cFolder = new Folder("C文件夹");

        folder.add(textFile1);
        folder.add(imagerFile1);
        folder.add(cFolder);

        //向C中添加文件
        TextFile cText = new TextFile("c_1.txt");
        ImagerFile cImage = new ImagerFile("c_1.jpg");
        VideoFile cVideo = new VideoFile("c_1.rmvb");

        cFolder.add(cText);
        cFolder.add(cImage);
        cFolder.add(cVideo);

        folder.display();
        System.out.println("--------------");
        //遍历C文件夹
        cFolder.display();
        //将c_1.txt删除
        cFolder.remove(cText);

        System.out.println("------------------------------");
        folder.display();
        System.out.println("--------------");
        cFolder.display();
    }
}
